<?php

namespace Orqlog\Yacampaign\Domain\Model\Impl;

use Orqlog\Yacampaign\Domain\Model\ValidatorInterface;
use Orqlog\Yacampaign\Exception\IllegalArgumentException;

class CampaignValidator implements ValidatorInterface 
{
    public function validate(Object $campaign):void
    {
        if (!is_null($campaign->getEndAt()) && !is_null($campaign->getStartAt())) {
            if ($campaign->getEndAt() <= $campaign->getStartAt()) {
                throw new IllegalArgumentException("End time can not be ahead of start time!", 1591674076);
            }
        }
    }
}